import javax.swing.*;
import java.sql.*;

/*学生成绩管理系统 版本T1.0学生操作界面*/
public class Do extends JFrame {
    String ad = "", y = "";     //ad表示即将要访问的数据库名称（即访问者的身份），y表示访问者的用户名

    public Do(String u, String x) {
        ad = u;
        y = x;
        setSize(700, 450);
        setVisible(true);
    }

    //得到该学生的全部信息
    int getStudent() {
        String url = "jdbc:odbc:SMSystem";
        String user = " ";
        String password = " ";
        String id[], n[], pwd[], sc[];
        double g1[], g2[], g3[];
        Connection con;
        Statement stm;
        ResultSet rs;
        int i = 0, j = 0, a = 0;        //a=0时是未设置学生信息或者没设置成功
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection(url, "", "");
            stm = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            rs = stm.executeQuery("SELECT * FROM " + ad);
            while (rs.next()) {
                j++;
            }
            id = new String[j];
            n = new String[j];
            pwd = new String[j];
            sc = new String[j];
            g1 = new double[j];
            g2 = new double[j];
            g3 = new double[j];

            rs.beforeFirst();   //游标返回开头位置
            for (i = 0; i < j; i++) {
                rs.next();
                id[i] = rs.getString(2);
                n[i] = rs.getString(3);
                pwd[i] = rs.getString(4);
                sc[i] = rs.getString(5);
                g1[i] = rs.getDouble(9);
                g2[i] = rs.getDouble(10);
                g3[i] = rs.getDouble(11);
            }
            rs.close();
            stm.close();
            con.close();

        } catch (SQLException sqle) {
            System.out.println(1 + sqle.toString());
        } catch (Exception e) {
            System.out.println(2 + e.toString());
        }
        //JOptionPane.showMessageDialog(null,"学号/工号/密码不正确！\n请重新输入！","友情提示",1);
        return a;
    }

}